ActionScript 3

stop();

    

[SWF(backgroundColor="0x000000" , width="1024" , height="768")]

    

var YearData = 2011;

    

var BoroughName;

    

var ArrayIndex;

    

var Offset;

    

var LastI = 0;

    

var BoroughColour;

    

var Statistics = -2;

    

var BoroughsArray:Array = new Array("City",320,370,100,89.9,100,"Barking",600,300,79.2,79.8,81.9,"Barnet",250,160,91.3,87.6,92,"Bexley",540,380,85,81.2,92,"Brent",180,300,75.2,81.4,86.8,"Bromley",470,450,87.8,89.8,87,"Camden",250,230,82.6,93.3,97.2,"Croydon",400,520,85.9,86.8,91.1,"Ealing",180,370,91.6,90.6,86,"Enfield",320,160,85.4,85.8,86.3,"Greenwich",470,380,89.8,85.3,86.2,"Hackney",390,300,73.9,84.6,90.8,"Fulham",250,370,87,88.8,85.9,"Haringey",320,230,87.4,91.2,92.4,"Harrow",180,230,88.4,78.6,87.3,"Havering",600,230,75.3,79.5,82.7,"Hillingdon",110,230,89.9,81.7,88.1,"Hounslow",110,300,89.4,87.2,83.7,"Islington",390,230,88.8,87.3,87.9,"Chelsea",250,300,91,93.8,89.5,"Kingston",120,450,84.4,85.9,92.6,"Lambeth",330,450,84.1,88.2,87.6,"Lewisham",400,450,90.6,92.1,93.5,"Merton",260,450,83.7,91.3,88,"Newham",530,300,83.7,89.3,87.6,"Olympic",540,450,83.1,84.9,99,"Redbridge",530,230,80,85.6,93,"Richmond",110,370,90,92.8,96.6,"Southwark",400,380,85.4,83.7,93,"Sutton",200,530,88.7,89.8,92.9,"Tower",460,300,83.5,82.1,92.8,"Waltham",460,230,87.4,87.3,93.7,"Wandsworth",190,450,92.9,85.6,93.3,"Westminster",320,300,92.1,89.6,90);

    

var textArray:Array = new Array(34);

    

textArray[0] = "The Square Mile was once the old city contained within the medieval walls, a history remembered each November in the pomp of the Lord Mayor's Show. Now it is the nation's financial centre and embodies the capital's mix of tradition and change. A place of mighty skyscrapers, this tiny area, only twenty minutes walk from one side to the other, generates 3% of the UK's income.";

textArray[1] = "Barking and Dagenham lies to the east of central London. Areas of interest within the borough include the ruined Anglo-Saxon Barking Abbey, built in 666AD. The Abbey is the venue for the Barking Carnival, taking place in May, which has an open-air concert of classical music as well as children's rides and a pageant.";

textArray[2] = "Barnet, one of the largest London boroughs, is home to the Hendon Aerodrome - the birthplace of British aviation and now RAF Museum. Visitors can gaze at over 70 full-sized aircraft as well as a flight simulator, 'Touch and Try' Jet Provost Trainer and Eurofighter 2000 Theatre.";

textArray[3] = "Although only 12 miles south east of central London (30 minutes by train), Bexley boasts over 1500 acres of open space and green parkland. Danson Park, believed to have been landscaped by the famous 'Capability Brown', is the setting for many of Bexley's annual summer events. ";

textArray[4] = "Brent's most famous feature is the legendary Wembley Stadium, the home of English football. Wembley Arena also attracts huge crowds and is one the capital's largest music venues. Brent is a multi-cultural heartland and offers fascinating glimpses into London's many faiths. The Hindu Temple in Neasden, The Shri Swaminarayan Mandir, was carved in India but assembled in North London and rises spectacularly out of its urban surroundings.";

textArray[5] = "Bromley is the largest of the London boroughs and promotes itself as the clean and green borough. It plays host every year to the Biggin Hill Air Fair held in June at Biggin Hill Airport, an important airfield during the Battle of Britain. Bromley is home to Crystal Palace Park boasting London's largest maze, as well as Crystal Palace Bowl. The latter is the venue for many summer concerts, including the Bank Holiday firework spectacular held in August and the Best of Last Night of the Proms.";

textArray[6] = "Camden is one of London's liveliest boroughs and the centre of the capital's underground music scene with a plethora of seductively scuzzy venues. The locks along Regent's Canal are the focus for some London's most varied shopping, with fashion, antiques, music, arts, crafts and bric-a-brac filling this labyrinth of boutiques and markets.";

textArray[7] = "Strategically placed between London and Gatwick, Croydon has excellent rail links to the capital. As well as boasting one of the most extensive shopping centres outside London's West End, the area's Surrey Street Market has traded since 1276 and is the oldest in the country.";

textArray[8] = "Ealing is one of west London's prettiest boroughs and hosts Britain's largest free jazz festival each year in August. The festival features a wide variety of bands playing lunch-time and evening concerts each day in Walpole Park. Ealing is a shopper's paradise with everything from major chains to specialist shops, an antiques and craft market, farmers' market and the capital's only remaining agricultural market in Southall Park.";

textArray[9] = "Enfield is the former hunting ground to the Kings of England and is as rich in history as it is in present day entertainment with a choice of events, theatres, cinemas and sports facilities. Delve into the past and follow in the footsteps of literary figures such as Thomas Hardy and John Keats, who spent most of his early years in Enfield and Edmonton.";

textArray[10] = "The London Borough of Greenwich lies on the south bank of the Thames. Rich in maritime history, Greenwich also has an outstanding architectural heritage. Many of its buildings are designed by well known English architects, including the Royal Naval College, the National Maritime Museum and the Royal Observatory built by Sir Christopher Wren for King Charles II. At the Royal Observatory visitors can stand astride Longitude Zero with one foot in the eastern and the other in the western hemisphere.";

textArray[11] = "Hackney possesses a rich mix of cultures and traditions. Popular destinations include super-trendy Shoreditch, a thriving cultural fringe of the City of London with a wide range of restaurants, bars, nightclubs and comedy venues. Visit the acclaimed Geffrye Museum which tells the history of domestic furniture from 1600 to the 1950s. The area is filled with thriving street markets including Petticoat Lane, Brick Lane and Ridley Road in Dalston which offers goods from across the world in a friendly, bustling atmosphere.";

textArray[12] = "Hammersmith and Fulham is a borough that brims with history. Attractions include Fulham Palace, which features a Tudor courtyard, 18th-century walled garden, botanical collection and museum. Kelmscott House, home of William Morris the famous 19th-century English poet and artist, features changing exhibitions of Morris embroideries and Pre-Raphaelite drawings.";

textArray[13] = "Haringey is famous for its literary connections such as Sir John Betjeman, who lived in West Hill as a child and also Karl Marx who is buried in nearby Highgate Cemetery. In the Western half of the borough stands Alexandra Palace, the last great Victorian exhibition space in Europe and the birth place of television. It boasts panoramic views over London and plays host to many major annual events.";

textArray[14] = "Harrow is home to one of Britain's finest public schools, Harrow School, based in Harrow-on-the-Hill, which offers three different guided tours are offered during term-time. A village atmosphere prevails in areas such as Pinner and Stanmore and there is a plethora of fine buildings dating back to medieval times. ";

textArray[15] = "Havering sits on the north-east edge of the capital with an area approaching 40 square miles. Half of Havering is situated in the Green Belt and boasts three country parks, including Havering Country Park, a favourite riding and hot-air ballooning location, Hornchurch Country Park which is excellent for birdwatchers, and Bedfords Park - a haven for deer. ";

textArray[16] = "Hillingdon is London's least densely populated borough, with a large tract of Green Belt land that includes over 800 acres of woodland. The Colne Valley, once part of the Grand Union Canal and a major trade route, is now a beautiful spot for walking, fishing and birdwatching. ";

textArray[17] = "Hounslow boasts a wealth of heritage attractions, beautiful parks, open country areas and riverside walks. The River Thames winds its way along the southern boundary where there are delightful stretches, with historic Thameside inns, such as Strand-on-the-Green, Chiswick Mall and Old Isleworth.";

textArray[18] = "Islington is traditionally a mecca for the cream of London's liberal, journalists, writers and artists. This vibrant borough boasts a thriving fringe theatre scene, a wealth of fantastic restaurants and vibrant nightlife. Islington is the best place to buy antiques in London. Spend an afternoon browsing the specialist shops and boutiques in the renowned Camden Passage Antiques Market.";

textArray[19] = "Kensington and Chelsea is renowned for its thriving, cosmopolitan atmosphere. The borough has many famous shopping areas including the King's Road, High Street Kensington and Knightsbridge, home to Harrods. Escape the crowds with a stroll through one of several beautiful parks or visit one of the area's many amazing museums, including the Natural History Museum, the Victoria and Albert Museum and the Science Museum. ";

textArray[20] = "Kingston upon Thames is located in south west London and is a commuter heartland. Once an historic market town it now boasts attractions old and new. The town is steeped in history, seven Kings were crowned on Kingston's Coronation Stone in the 10th century.";

textArray[21] = "Stretching from the South Bank of the Thames to the suburbs of Streatham and Norwood, Lambeth is bursting with exciting attractions. Brixton, one of the borough's most multi-cultural areas has a thriving shopping centre and market selling ethnic foods, household goods, jewellery and second-hand goods. Its thriving nightlife makes it the heart of London's urban scene, and it also has the best live venue in London, the Brixton Academy.";

textArray[22] = "Blackheath is Lewisham's major centre and was once a fashionable suburb for wealthy city merchants between the 17th and 19th centuries. This wealth is still reflected in its attractive architecture, and large houses. Blackheath has fine restaurants, cosy pubs, stylish shops and an appealing village-like atmosphere. The village heath adjourns Greenwich Park and is a popular location for kite-flyers on a Sunday.";

textArray[23] = "Merton is home to the legendary Wimbledon Lawn Tennis Championships, held every year for two weeks during June/July. The Wimbledon Lawn Tennis Museum, open throughout the year, provides visitors with views over the Centre Court and films of matches.";

textArray[24] = "Newham is in the heart of London's historic Docklands. With fast rail links to the continent planned for Stratford and London City Airport overlooking the docks, the borough is set to become a hub of the international travel network. Historic features of the area include the Royal Docks, built in the 1850s, which stretch from one side of Newham to the other and enclose the country's largest area of dock water.";

textArray[25] = " ";

textArray[26] = "Redbridge is a diverse borough with lush green spaces, sports facilities and bustling shopping centres. Though only seven miles from central London, it has a distinctly countryside feel with ancient Epping Forest falling within its boundaries. This 6000-acre wood boasts riverside trails, nature conservation areas, a watersports lake, two country parks and a number of other visitor attractions.";

textArray[27] = "Home to the rich and famous for centuries, from Henry VIII to Mick Jagger, Richmond-upon-Thames boasts magnificent houses and gardens, many of which stem from the river that forms the heart of this popular enclave. Discover world-renowned Hampton Court Palace and maze, the oldest Tudor palace in England, and Kew Gardens, with its 300 acres containing collections of over 40,000 varieties of plants. Marble Hill House, the Thames-side villa built between 1724-29 for Henrietta Howard, mistress of King George III, is also open to visitors.";

textArray[28] = "Southwark is the historical home of the capital's arts and entertainments industry. London's first theatres, the Globe, the Hope and The Rose were all built there in the 16th century and Shakespeare's plays first performed there. The rebuilt Globe theatre is now one of the best theatres in London, while the neighbouring Tate Modern, housed in the stupendous Bankside Power Station, is among the world's most popular art galleries. London's modern City Hall and the magnificent, gothic Southwark Cathedral, complete a remarkable set of buildings that show five centuries of London's architectural achievements.";

textArray[29] = "Situated on the southern edge of London, Sutton is an excitingly diverse borough. Visitors will want to check out the 16th-century timber framed Whitehall in the heart of the Cheam Village conservation area and Little Holland House, inspired by the Arts and Crafts Movement.";

textArray[30] = "Tower Hamlets is the heart of London's East End and takes its name from the Tower of London, located within the borough's boundaries. The borough is dominated by the White Tower, built in the eleventh century and home to the crown jewels, royal armouries, yeoman warders and the famous ravens.";

textArray[31] = "The Borough of Waltham Forest lies to the east of central London, with its centre, Walthamstow, located 30 minutes from the city. For shoppers, Walthamstow is home to Britain's longest street market, providing nearly one mile of stalls selling everything from hardware to food and clothes. Five minutes walk away from the hustle and bustle of the market is Walthamstow Village, a designated conservation area, where visitors can get a glimpse of the origins of Walthamstow.";

textArray[32] = " ";

textArray[33] = "It is impossible to even begin to capture everything that Westminster - the seat of Britain's government - has to offer. From stately Buckingham Palace and the Houses of Parliament to the raucous Soho nightlife, from the bustle of Oxford Street, to the rolling vistas of the Royal Parks it would take weeks to describe everything to see and do in London's heartland.";

textArray[34] = " ";

    

var buttonBoroughStats:TextField = new TextField();

    

var titleText:TextField = new TextField();

titleText.x = 180;

titleText.y = 30;

titleText.width = 420;

titleText.height = 30;

titleText.selectable = false;

var format:TextFormat = new TextFormat();

format.color = 0x6499AB;

format.size = 28;

format.align = "center"

titleText.defaultTextFormat = format;

titleText.text = "Internet Usage in London Boroughs";

addChild(titleText);

    

var yearButtons:Array = [];

    

format.color = 0x04394B;

format.size = 14;

format.align = "center"

    

for (var i:int = 0; i < 3; i++) {

    graphics.beginFill(0x333333, 1);

    graphics.drawEllipse(254+i*100, 80, 68, 30);

    graphics.endFill();

    var buttonYear:TextField = new TextField();

    buttonYear.x = 254 + i*100;

    buttonYear.y = 87;

    buttonYear.width = 70;

    buttonYear.height = 20;

    buttonYear.selectable = false;

    buttonYear.defaultTextFormat = format;

    buttonYear.text = "201"+(i+1);

    addChild(buttonYear);

    buttonYear.addEventListener(MouseEvent.CLICK, SetYear(2011+i));

    yearButtons.push(buttonYear);

};

    

var boxButton:Sprite = new Sprite();

    

    buttonBoroughStats.addEventListener(MouseEvent.CLICK, clearStatistics);

    boxButton.addEventListener(MouseEvent.CLICK, clearStatistics);

    

var boroughButtons:Array = [];

var keyButtons:Array = [];

var positionKey_x;

var positionKey_y;

    

format.color = 0x6499AB;

format.size = 13;

format.align = "left"

for (i = 0; i < 34; i++) {

    

    var buttonName:Sprite = new Sprite();

    buttonName.x = BoroughsArray[i*6+1];

    buttonName.y = BoroughsArray[i*6+2];

    buttonName.graphics.beginFill(0x6499AB, 1);

    buttonName.graphics.drawEllipse(0, 0, 68, 48);

    buttonName.graphics.endFill();

    addChild(buttonName);

    buttonName.addEventListener(MouseEvent.CLICK, Stats(0));

    buttonName.addEventListener(MouseEvent.MOUSE_OVER, Over(i));

    buttonName.addEventListener(MouseEvent.MOUSE_OUT, Out(0));

    boroughButtons.push(buttonName);

    var keyName:TextField = new TextField();

    positionKey_x = 780;

    positionKey_y = 38 + i * 20;

    if (i > 16){

        positionKey_x = positionKey_x + 134;

        positionKey_y = positionKey_y - 340;

    };

    keyName.x = positionKey_x;

    keyName.y = positionKey_y;

    keyName.width = 80;

    keyName.height = 20;

    keyName.defaultTextFormat = format;

    keyName.selectable = false;

    keyName.text = BoroughsArray[i*6];

    addChild(keyName);

    keyName.addEventListener(MouseEvent.MOUSE_OVER, DisplayData(i));

    keyButtons.push(keyName);

};

var boroughButtonsText:TextField = new TextField();

boroughButtonsText.addEventListener(MouseEvent.CLICK, Stats(0));

boroughButtonsText.addEventListener(MouseEvent.MOUSE_OVER, OverText);

boroughButtonsText.addEventListener(MouseEvent.MOUSE_OUT, Out(0));

var textBorough:TextField = new TextField();

//added key to borough list

var keyBoxes:Array = [];

for (i = 0; i < 3; i++) {

    var keyBox:Sprite = new Sprite();

    keyBox.x = 1280 + i * 12;

    keyBox.y = i*16-100;

    keyBox.graphics.beginFill(0xFFFFFF, 1);

    keyBox.graphics.drawEllipse(0, 0, 12, 10);

    keyBox.graphics.endFill();

    addChild(keyBox);

    keyBoxes.push(keyBox);

};

SetYear_(); // Sets the year at start

function clearStatistics(event:MouseEvent):void

{

    boxButton.y = -1000;

    buttonBoroughStats.x = -1000;

    Statistics = -1;

    OutOnly(ArrayIndex);

    for (i = 0; i < 34; i++) {

        boroughButtons[i].alpha = 1;

    };

};

function SetYear(year:int):Function {

    return function(event:MouseEvent):void{

        YearData = year;

        SetYear_();

    };

};

function SetYear_():void{

    if (Statistics < 0){

var myColorTransform = new ColorTransform();

var Offset;

myColorTransform.color = 0x666666;

for (i = 0; i < 3; i++) {

yearButtons[i].transform.colorTransform = myColorTransform;

};

myColorTransform.color = 0x6499AB;

yearButtons[YearData - 2011].transform.colorTransform = myColorTransform;

Offset = YearData - 2008;

var i:int;

for (i = 0; i < 34; i++)

{

var Stats:int = BoroughsArray[i*6+Offset];

if (Stats >= 90)

{

boroughButtons[i].graphics.beginFill(0x3CBFF0, 1);

}

else if (Stats >= 80)

{

boroughButtons[i].graphics.beginFill(0x0682A6, 1);

}

else

{

boroughButtons[i].graphics.beginFill(0x04586C, 1);

}

boroughButtons[i].graphics.drawEllipse(0, 0, 68, 48);

boroughButtons[i].graphics.endFill();

};

}

};

function Over(i:int):Function {

return function(event:MouseEvent):void{

ArrayIndex = LastI;

OutOnly(ArrayIndex);

ArrayIndex = i;

OverEither();

};

};

function OverText(event:MouseEvent):void{ // Listner always sends at least 1 variable

OverEither();

};

function OverEither(){

if (Statistics < 0){

i = ArrayIndex;

YearColour();

boroughButtons[i].alpha = 0.17;

var heightData = (BoroughsArray[i*6+(YearData-2008)]-74)/1.25;

graphics.lineStyle(1, 0x00384C);

graphics.beginFill(BoroughColour, 1);

graphics.drawEllipse(BoroughsArray[i*6+1], BoroughsArray[i*6+2]-heightData, 68, 48);

graphics.endFill();

BoroughName = BoroughsArray[i*6];

boroughButtonsText.x = BoroughsArray[i*6+1];

boroughButtonsText.y = BoroughsArray[i*6+2]+17-heightData;

boroughButtonsText.width = 68;

boroughButtonsText.height = 20;

boroughButtonsText.selectable = false;

var format:TextFormat = new TextFormat();

//format.font = "Gill Sans";

format.color = 0xFFFFFF;

format.size = 12;

format.align = "center"

boroughButtonsText.defaultTextFormat = format;

boroughButtonsText.text = BoroughName;

addChild(boroughButtonsText);

keyColours();

descriptionText();

};

};

function Stats(i:int):Function {

return function(event:MouseEvent):void{

if (Statistics < 0){

for (i = 0; i < 34; i++) {

boroughButtons[i].alpha = .3;

};

i = ArrayIndex;

BoroughName = BoroughsArray[i*6];

YearColour();

boxButton.x = 200;

boxButton.y = 180;

boxButton.graphics.beginFill(BoroughColour, 1);

boxButton.graphics.drawEllipse(0, 0, 320, 320);

boxButton.graphics.endFill();

addChild(boxButton);

buttonBoroughStats.x = 200;

buttonBoroughStats.y = 230;

buttonBoroughStats.width = 320;

buttonBoroughStats.autoSize = "center";

buttonBoroughStats.selectable = false;

buttonBoroughStats.backgroundColor = BoroughColour;

buttonBoroughStats.background = true;

var format:TextFormat = new TextFormat();

//format.font = "Gill Sans";

format.color = 0xFFFFFF;

format.size = 24;

format.align = "center"

buttonBoroughStats.defaultTextFormat = format;

buttonBoroughStats.text = BoroughName + "\n\n2011: " + BoroughsArray[i*6+3] + "%\n\n2012: " + BoroughsArray[i*6+4] + "%\n\n2013: "+ BoroughsArray[i*6+5] + "%";

var boroughName:TextFormat = new TextFormat();

boroughName.size = 40;

var startRangeT:uint = buttonBoroughStats.text.indexOf("2011");

buttonBoroughStats.setTextFormat(boroughName, 0, startRangeT);

var activeYear:TextFormat = new TextFormat();

activeYear.size = 36;

var startRange:uint = buttonBoroughStats.text.indexOf(YearData);

var Stats = BoroughsArray[i*6+Offset];

var stringNo = Stats.toString();

var endText:uint = buttonBoroughStats.text.indexOf(Stats)+5;

if (buttonBoroughStats.text.lastIndexOf("%") < endText)

{

endText = buttonBoroughStats.text.lastIndexOf("%")+1;

};

buttonBoroughStats.setTextFormat(activeYear, startRange, endText);

Statistics = ArrayIndex;

addChild(buttonBoroughStats);

};

};

};

// Mouse moves off the borough button

function Out(i:int):Function {

return function(event:MouseEvent):void{

i = ArrayIndex;

OutOnly(i);

};

};

// Mouse moves off the borough button

function OutOnly(i):void{

if (Statistics < 0){

var x_position = BoroughsArray[i*6+1];

var y_position = BoroughsArray[i*6+2];

// Off Borough Button

if (mouseX < x_position+10 || mouseX > x_position+58 || mouseY < y_position+10 || mouseY > y_position+3 || Statistics == -1)

{

boroughButtonsText.x = -1000;

boroughButtonsText.text = "";

graphics.lineStyle(1, 0x000000);

graphics.beginFill(0x000000, 1);

boroughButtons[i].alpha = 1;

var heightData = (BoroughsArray[i*6+(YearData-2008)]-74)/1.25;

graphics.drawEllipse(BoroughsArray[i*6+1]-1, BoroughsArray[i*6+2]-heightData-1, 70, 50);

graphics.endFill();

};

};

};

// Added Code for key

function keyColours():void{

var Offset;

var keyColour;

var positionKey_x;

var positionKey_y;

for (i = 0; i < 3; i++) {

var Stats = BoroughsArray[ArrayIndex*6+3+i];

keyColour = "0x00384C";

if (Stats > 90)

{

keyColour = "0x3CBFF0";

}

else if (Stats > 80)

{

keyColour = "0x0082A6";

};

positionKey_x = 730+i*14;

positionKey_y = 40 + ArrayIndex*20;

if (ArrayIndex > 16){

positionKey_x = positionKey_x + 134;

positionKey_y = positionKey_y - 340;

};

keyBoxes[i].x = positionKey_x;

keyBoxes[i].y = positionKey_y;

keyBoxes[i].graphics.beginFill(keyColour, 1);

keyBoxes[i].graphics.drawEllipse(0, 0, 12, 10);

keyBoxes[i].graphics.endFill();

};

};

function DisplayData(i:int):Function {

return function(event:MouseEvent):void{

if (Statistics < 0){

ArrayIndex = LastI;

OutOnly(ArrayIndex);

ArrayIndex = i;

keyColours();

descriptionText();

OverEither();

LastI = i;

};

};

};

function descriptionText():void{

textBorough.x = 780;

textBorough.y = 400;

textBorough.width = 200;

textBorough.height = 600;

textBorough.wordWrap = true;

textBorough.selectable = false;

var format:TextFormat = new TextFormat();

//format.font = "Gill Sans Semibold";

format.color = 0x6499AB;

format.size = 14;

format.align = "left"

textBorough.defaultTextFormat = format;

textBorough.text = textArray[ArrayIndex];

addChild(textBorough);

};

function YearColour():void{

Offset = YearData - 2008;

var Stats = BoroughsArray[ArrayIndex*6+Offset];

BoroughColour = "0x04586C";

if (Stats >= 90)

{

BoroughColour = "0x3CBFF0";

}

else if (Stats >= 80)

{

BoroughColour = "0x0682A6";

};

};